﻿#ifndef CSqlOper_H
#define CSqlOper_H
/********************************************************************************
** @ Date:2025/04/17
** @ Author: HanJiaXin
** @ Description:数据库语句
** @ Version:1.0.0
** @ ClassName:
** @ Fun:
********************************************************************************/
#include "Header.h"
#include "dbstruct.h"
class CDevDataCam;

class CSqlOper
{
public:
	static CSqlOper& instance()
	{
		static CSqlOper instance;
		return instance;
	}

	bool selectDevInfo(QString& sDevGuid, QVector<QSqlRecord>& vecRecord, QString& sErrMsg);
	bool insertDevInfo(QString& sDevGuid, QString& sDevName, QString& sCamerDevGuid, QString& sErrMsg);
	bool deleteDevInfo(QString sDevId, QString& sErrMsg);

	bool selectCamerInfo(QString sDevGuid, QVector<QSqlRecord>& vecRecord, QString& sErrMsg);
	bool insertDefDevCfg(QString sDevGuid, QString sDevName, QString& sErrMsg);
	bool selectCamerInfo(QString sDevGuid, CDevDataCam* pDevData, QString& sErrMsg);
	bool updateCamerInfo(QString sDevGuid, QString sCamerName, QString sCamerIp, int nPort, QString sCamerUser, QString sCamerPasswd, QString sRecordPath, QString sRtspUrl, 
		QString sAlgType, int nChannel, QString sServerIp, int nVideoType, int nChannelNo, QString sRtspHW, QString& sErrMsg);
	bool insertCamerInfo(QString sDevGuid, QString sCamerName, QString sCamerIp, int nPort, QString sCamerUser, QString sCamerPasswd, QString sRecordPath, QString sRtspUrl, 
		QString sAlgType, int nChannel, QString sServerIp, int nVideoType, int nChannelHW, QString sRtspHW, QString& sErrMsg);
	bool deleteCamerInfo(QString sDevGuid, QString& sErrMsg);
	bool insertAlarmRecord(QString sGuid, QString sDevGuid, QString sCamerName, QString sCamerIp, int nChannel, QDateTime dAlarmTime,
		QString sEventType, QString sEventState, QString sImgUrl, QString sCamerUser, QString sCamerPassWd, QString sAlarmDesc, QString& sErrMsg);
	bool selectQuertAlarmRecord(QString sDevGuid, QVector<QSqlRecord>& vecRecord, QString& sErrMsg);
	bool selectQuertAlarmRecordByGuid(QString sGuid, QVector<QSqlRecord>& vecRecord, QString& sErrMsg);
	bool updateAlarmRecord(QString sGuid, QString& sErrMsg);
	bool selectCamerName(QVector<QSqlRecord>& vecRecord, QString& sErrMsg);
	bool selectAlarmResult(QString sDevGuid, QString sAlarmType, QString sStartTime,QString sEndTime, QVector<QSqlRecord>& vecRecord, QString& sErrMsg);
	bool selectAlarmResult(QString sStartTime, QString sEndTime, QVector<QSqlRecord>& vecRecord, QString& sErrMsg);
	bool selectTagID(QString& sDevGuid, QString& sTagID, QVector<QSqlRecord>& vecRecord, QString& sErrMsg);
	bool insertTagID(QString& sDevGuid, QString& sTagID, QString& sTagAddr, QString& sErrMsg);
	bool updateTagID(QString& sDevGuid, QString& sTagID, QString& sTagAddr, QString& sErrMsg);

	bool selectResultLastTime(QVector<QSqlRecord>& vecRecord,QString sErrMsg);
	bool insertResult(QString sGuid,int nResultType,QString sResultName,QDateTime dTime,QString sPath,QString sHttpUrl,QString& sErrMsg);
	bool selectServerChannel(QString sServerIp, int nChannel, QVector<QSqlRecord>& vecInfo, QString sErrMsg);
	bool selectResult(QString sStartTime, QString sEndTime, QVector<QSqlRecord>& vecInfo, QString& sErrMsg);
	bool insertPubCardCfg(QString sCardGuid, int nCardType, QString sDevList, QString& sErrMsg);
	bool selectPubCardCfg(QString sCardGuid,QVector<QSqlRecord>& vecInfo,QString& sErrMsg);
	bool updatePubCardCfg(QString sCarGuid, QString sDevList, QString& sErrMsg);
	bool initSql();

private:
	CSqlOper();
	~CSqlOper();

	CSqlDllOper* m_pDbDllOper;
};

#endif // 